<template>
    <div class="index-lists">
        <!-- <el-card class="!border-none" shadow="never"> -->
        <!-- <el-form
        ref="formRef"
        class="mb-[-16px]"
        :model="queryParams"
        :inline="true"
      >
        <el-form-item label="案件名称" prop="caseName">
          <el-input class="w-[280px]" v-model="queryParams.caseName" />
        </el-form-item>
        <el-form-item label="案件类型" prop="caseType">
          <el-select v-model="queryParams.caseType" class="w-[280px]" clearable>
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="业务类型" prop="businessType">
          <el-select
            v-model="queryParams.businessType"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="申请类型" prop="putinType">
          <el-select
            v-model="queryParams.putinType"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="承办部门" prop="undertakingDepartment">
          <el-select
            v-model="queryParams.undertakingDepartment"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="处理人" prop="conductor">
          <el-input class="w-[280px]" v-model="queryParams.conductor" />
        </el-form-item>
        <el-form-item label="税率" prop="taxRate">
          <el-select v-model="queryParams.taxRate" class="w-[280px]" clearable>
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="成本类型" prop="costType">
          <el-select v-model="queryParams.costType" class="w-[280px]" clearable>
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="成本" prop="cost">
          <el-input class="w-[280px]" v-model="queryParams.cost" />
        </el-form-item>
        <el-form-item label="贡献额" prop="contributionPool">
          <el-input class="w-[280px]" v-model="queryParams.contributionPool" />
        </el-form-item>
        <el-form-item label="所属分布" prop="ownershipDistribution">
          <el-select
            v-model="queryParams.ownershipDistribution"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="选择已有案件" prop="haveCase">
          <el-input class="w-[280px]" v-model="queryParams.haveCase" />
        </el-form-item>
        <el-form-item label="申请国家（地区）" prop="designatedCountry">
          <el-input class="w-[280px]" v-model="queryParams.designatedCountry" />
        </el-form-item>
        <el-form-item label="商标类别" prop="brandType">
          <el-select
            v-model="queryParams.brandType"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="类别数量" prop="classQuantity">
          <el-input class="w-[280px]" v-model="queryParams.classQuantity" />
        </el-form-item>
        <el-form-item label="申请数量" prop="quantity">
          <el-input class="w-[280px]" v-model="queryParams.quantity" />
        </el-form-item>
        <el-form-item label="官费" prop="officialFee">
          <el-input class="w-[280px]" v-model="queryParams.officialFee" />
        </el-form-item>
        <el-form-item label="代理费" prop="agencyFee">
          <el-input class="w-[280px]" v-model="queryParams.agencyFee" />
        </el-form-item>
        <el-form-item label="第三方费" prop="hirdPartyPayment">
          <el-input class="w-[280px]" v-model="queryParams.hirdPartyPayment" />
        </el-form-item>
        <el-form-item label="签单金额" prop="signedAmount">
          <el-input class="w-[280px]" v-model="queryParams.signedAmount" />
        </el-form-item>
        <el-form-item label="开票金额" prop="invoiceValue">
          <el-input class="w-[280px]" v-model="queryParams.invoiceValue" />
        </el-form-item>
        <el-form-item label="实收金额" prop="fundsReceived">
          <el-input class="w-[280px]" v-model="queryParams.fundsReceived" />
        </el-form-item>
        <el-form-item label="实收日期" prop="paidupDate">
          <el-input class="w-[280px]" v-model="queryParams.paidupDate" />
        </el-form-item>
        <el-form-item label="我方案号" prop="planNumber">
          <el-input class="w-[280px]" v-model="queryParams.planNumber" />
        </el-form-item>
        <el-form-item label="案件状态" prop="caseStatus">
          <el-select
            v-model="queryParams.caseStatus"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="当前案件环节" prop="caseLink">
          <el-input class="w-[280px]" v-model="queryParams.caseLink" />
        </el-form-item>
        <el-form-item label="备注" prop="remark">
          <el-input class="w-[280px]" v-model="queryParams.remark" />
        </el-form-item>
        <el-form-item label="案件类型id" prop="caseNameid">
          <el-input class="w-[280px]" v-model="queryParams.caseNameid" />
        </el-form-item>
        <el-form-item label="业务类型id" prop="businessTypeid">
          <el-input class="w-[280px]" v-model="queryParams.businessTypeid" />
        </el-form-item>
        <el-form-item label="承办部门id" prop="undertakingDepartmentid">
          <el-input
            class="w-[280px]"
            v-model="queryParams.undertakingDepartmentid"
          />
        </el-form-item>
        <el-form-item label="所属分部id" prop="ownershipDistributionid">
          <el-input
            class="w-[280px]"
            v-model="queryParams.ownershipDistributionid"
          />
        </el-form-item>
        <el-form-item label="成本类型id" prop="costTypeid">
          <el-input class="w-[280px]" v-model="queryParams.costTypeid" />
        </el-form-item>
        <el-form-item label="相关类型id" prop="correlationTypeid">
          <el-input class="w-[280px]" v-model="queryParams.correlationTypeid" />
        </el-form-item>
        <el-form-item label="是否立案" prop="isRegister">
          <el-select
            v-model="queryParams.isRegister"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="是否作废" prop="isInvalid">
          <el-select
            v-model="queryParams.isInvalid"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="是否已有案件" prop="isExistingcase">
          <el-select
            v-model="queryParams.isExistingcase"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="是否需要纸质通知书" prop="isPapernotice">
          <el-select
            v-model="queryParams.isPapernotice"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="费用类型" prop="chargeType">
          <el-select
            v-model="queryParams.chargeType"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="币别" prop="currency">
          <el-input class="w-[280px]" v-model="queryParams.currency" />
        </el-form-item>
        <el-form-item label="金额" prop="sum">
          <el-input class="w-[280px]" v-model="queryParams.sum" />
        </el-form-item>
        <el-form-item label="预请款日" prop="advancePaymentDate">
          <daterange-picker
            v-model:startTime="queryParams.createTimeStart"
            v-model:endTime="queryParams.createTimeEnd"
          />
        </el-form-item>
        <el-form-item label="请款单号" prop="paymentRequestNumber">
          <el-input
            class="w-[280px]"
            v-model="queryParams.paymentRequestNumber"
          />
        </el-form-item>
        <el-form-item label="请款日期" prop="requestedDate">
          <daterange-picker
            v-model:startTime="queryParams.createTimeStart"
            v-model:endTime="queryParams.createTimeEnd"
          />
        </el-form-item>
        <el-form-item label="应收日期" prop="accountsDate">
          <daterange-picker
            v-model:startTime="queryParams.createTimeStart"
            v-model:endTime="queryParams.createTimeEnd"
          />
        </el-form-item>
        <el-form-item label="发票号" prop="invoiceNumber">
          <el-input class="w-[280px]" v-model="queryParams.invoiceNumber" />
        </el-form-item>
        <el-form-item label="费用名称" prop="chargeName">
          <el-input class="w-[280px]" v-model="queryParams.chargeName" />
        </el-form-item>
        <el-form-item label="费用描述" prop="chargeDepict">
          <el-input class="w-[280px]" v-model="queryParams.chargeDepict" />
        </el-form-item>
        <el-form-item label="费用描述英文" prop="chargeDepictfine">
          <el-input class="w-[280px]" v-model="queryParams.chargeDepictfine" />
        </el-form-item>
        <el-form-item label="应收金额" prop="extendedAmount">
          <el-input class="w-[280px]" v-model="queryParams.extendedAmount" />
        </el-form-item>
        <el-form-item label="折扣率" prop="discountRate">
          <el-input class="w-[280px]" v-model="queryParams.discountRate" />
        </el-form-item>
        <el-form-item label="数量" prop="count">
          <el-input class="w-[280px]" v-model="queryParams.count" />
        </el-form-item>
        <el-form-item label="汇率" prop="parities">
          <el-input class="w-[280px]" v-model="queryParams.parities" />
        </el-form-item>
        <el-form-item label="收款公司账户" prop="collectingCompanyAccount">
          <el-input
            class="w-[280px]"
            v-model="queryParams.collectingCompanyAccount"
          />
        </el-form-item>
        <el-form-item label="收款状态" prop="collectionStatus">
          <el-select
            v-model="queryParams.collectionStatus"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="账户明细" prop="accountDetails">
          <el-input class="w-[280px]" v-model="queryParams.accountDetails" />
        </el-form-item>
        <el-form-item label="开票时间" prop="slt">
          <daterange-picker
            v-model:startTime="queryParams.createTimeStart"
            v-model:endTime="queryParams.createTimeEnd"
          />
        </el-form-item>
        <el-form-item label="外方账单号" prop="externalBillingNumber">
          <el-input
            class="w-[280px]"
            v-model="queryParams.externalBillingNumber"
          />
        </el-form-item>
        <el-form-item label="外方账单日期" prop="externalBillingDate">
          <daterange-picker
            v-model:startTime="queryParams.createTimeStart"
            v-model:endTime="queryParams.createTimeEnd"
          />
        </el-form-item>
        <el-form-item label="垫交状态" prop="beddingCondition">
          <el-select
            v-model="queryParams.beddingCondition"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="垫交人" prop="handOver">
          <el-input class="w-[280px]" v-model="queryParams.handOver" />
        </el-form-item>
        <el-form-item label="费用备注" prop="expenseNote">
          <el-input class="w-[280px]" v-model="queryParams.expenseNote" />
        </el-form-item>
        <el-form-item label="费减类型" prop="reductionType">
          <el-select
            v-model="queryParams.reductionType"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="实际币别" prop="actualCurrency">
          <el-input class="w-[280px]" v-model="queryParams.actualCurrency" />
        </el-form-item>
        <el-form-item label="官方期限" prop="officialDeadline">
          <el-input class="w-[280px]" v-model="queryParams.officialDeadline" />
        </el-form-item>
        <el-form-item label="我方文号" prop="ourRef">
          <el-input class="w-[280px]" v-model="queryParams.ourRef" />
        </el-form-item>
        <el-form-item label="相关案名称" prop="relevantCaseName">
          <el-input class="w-[280px]" v-model="queryParams.relevantCaseName" />
        </el-form-item>
        <el-form-item label="相关申请类型" prop="correlationType">
          <el-select
            v-model="queryParams.correlationType"
            class="w-[280px]"
            clearable
          >
            <el-option label="请选择字典生成" value="" />
          </el-select>
        </el-form-item>
        <el-form-item label="操作人ID" prop="userId">
          <el-input class="w-[280px]" v-model="queryParams.userId" />
        </el-form-item>
        <el-form-item label="操作人名称" prop="userName">
          <el-input class="w-[280px]" v-model="queryParams.userName" />
        </el-form-item>
        <el-form-item label="修改人编号" prop="updateUserId">
          <el-input class="w-[280px]" v-model="queryParams.updateUserId" />
        </el-form-item>
        <el-form-item label="修改人名称" prop="updateUserName">
          <el-input class="w-[280px]" v-model="queryParams.updateUserName" />
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="resetPage">查询</el-button>
          <el-button @click="resetParams">重置</el-button>
        </el-form-item>
      </el-form> -->
        <!-- </el-card> -->
        <el-card class="!border-none mt-4" shadow="never">
            <div>
                <el-button v-perms="['case:add']" type="primary" @click="handleAdd()">
                    <template #icon>
                        <icon name="el-icon-Plus" />
                    </template>
                    添加案件
                </el-button>
            </div>
            <el-table class="mt-4" size="large" v-loading="pager.loading" :data="pager.lists" stripe>
                <el-table-column label="案件名称" prop="caseName" min-width="100" />
                <el-table-column label="案件类型" prop="caseType" min-width="100" />
                <el-table-column label="业务类型" prop="businessType" min-width="100" />
                <el-table-column label="申请类型" prop="putinType" min-width="100" />
                <el-table-column
                    label="申请国家（地区）"
                    prop="designatedCountry"
                    min-width="100"
                />
                <el-table-column label="类别数量" prop="classQuantity" min-width="100" />
                <el-table-column label="官费" prop="officialFee" min-width="100" />
                <el-table-column label="代理费" prop="agencyFee" min-width="100" />
                <el-table-column label="第三方费" prop="hirdPartyPayment" min-width="100" />
                <el-table-column label="签单金额" prop="signedAmount" min-width="100" />
                <el-table-column label="开票金额" prop="invoiceValue" min-width="100" />
                <el-table-column label="实收金额" prop="fundsReceived" min-width="100" />
                <el-table-column label="实收日期" prop="paidupDate" min-width="100" />
                <el-table-column label="我方案号" prop="planNumber" min-width="100" />
                <el-table-column label="案件状态" prop="caseStatus" min-width="100" />
                <el-table-column label="当前案件环节" prop="caseLink" min-width="100" />
                <el-table-column label="备注" prop="remark" min-width="100" />
              <el-table-column label="是否立案" prop="isRegister" min-width="100">
                <template #default="{ row }">
                  {{ row.isExistingcase === '1' ? '是' : '否' }}
                </template>
              </el-table-column>

                <el-table-column label="预请款日" prop="advancePaymentDate" min-width="100" />
                <el-table-column label="请款单号" prop="paymentRequestNumber" min-width="100" />
                <el-table-column label="请款日期" prop="requestedDate" min-width="100" />
                <el-table-column label="应收日期" prop="accountsDate" min-width="100" />
                <el-table-column label="发票号" prop="invoiceNumber" min-width="100" />
                <el-table-column label="费用名称" prop="chargeName" min-width="100" />
                <el-table-column label="数量" prop="count" min-width="100" />
                <el-table-column label="费减类型" prop="reductionType" min-width="100" />
                <el-table-column label="实际币别" prop="actualCurrency" min-width="100" />
                <el-table-column label="官方期限" prop="officialDeadline" min-width="100" />
                <el-table-column label="我方文号" prop="ourRef" min-width="100" />
                <el-table-column label="相关案名称" prop="relevantCaseName" min-width="100" />
                <el-table-column label="相关申请类型" prop="correlationType" min-width="100" />
                <el-table-column label="操作" width="120" fixed="right">
                    <template #default="{ row }">
                        <!-- <el-button
              v-perms="['case:edit']"
              type="primary"
              link
              @click="handleEdit(row)"
            >
              编辑
            </el-button> -->
                      <el-button
                          v-perms="['case:del']"
                          type="danger"
                          link
                          @click="handleDelete(row.id)"
                      >
                          删除
                      </el-button>
                    </template>
                </el-table-column>
            </el-table>
            <div class="flex justify-end mt-4">
                <pagination v-model="pager" @change="getLists" />
            </div>
        </el-card>
        <edit-popup v-if="showEdit" ref="editRef" @success="getLists" @close="showEdit = false" />
      <footer-btns>
        <div style="padding: 20px">
          <el-button v-perms="['basic:add']" type="primary" @click="handleSubmit">
            <template #icon>
              <icon name="el-icon-Plus" />
            </template>
            新增
          </el-button>
          <el-button
              v-perms="['customerlist:add/edit']"
              type="primary"
              @click="save()"
          >
            <template #icon>
              <icon name="el-icon-FolderChecked" />
            </template>
            保存
          </el-button>
          <el-button @click="resetParams">重置</el-button>
        </div>
      </footer-btns>
    </div>
</template>
<script lang="ts" setup name="case">
import { caseDelete, caseLists } from '@/api/case'
import { usePaging } from '@/hooks/usePaging'
import feedback from '@/utils/feedback'
import EditPopup from './caseEdit.vue'
const editRef = shallowRef<InstanceType<typeof EditPopup>>()
const showEdit = ref(false)
const queryParams = reactive({

    caseName: '',
    caseType: '',
    businessType: '',
    putinType: '',
    undertakingDepartment: '',
    conductor: '',
    taxRate: '',
    costType: '',
    cost: '',
    contributionPool: '',
    ownershipDistribution: '',
    haveCase: '',
    designatedCountry: '',
    brandType: '',
    classQuantity: '',
    quantity: '',
    officialFee: '',
    agencyFee: '',
    hirdPartyPayment: '',
    signedAmount: '',
    invoiceValue: '',
    fundsReceived: '',
    paidupDate: '',
    planNumber: '',
    caseStatus: '',
    caseLink: '',
    remark: '',
    caseNameid: '',
    businessTypeid: '',
    undertakingDepartmentid: '',
    ownershipDistributionid: '',
    costTypeid: '',
    correlationTypeid: '',
    isRegister: '',
    isInvalid: '',
    isExistingcase: '',
    isPapernotice: '',
    chargeType: '',
    currency: '',
    sum: '',
    advancePaymentDateStart: '',
    advancePaymentDateEnd: '',
    paymentRequestNumber: '',
    requestedDateStart: '',
    requestedDateEnd: '',
    accountsDateStart: '',
    accountsDateEnd: '',
    invoiceNumber: '',
    chargeName: '',
    chargeDepict: '',
    chargeDepictfine: '',
    extendedAmount: '',
    discountRate: '',
    count: '',
    parities: '',
    collectingCompanyAccount: '',
    collectionStatus: '',
    accountDetails: '',
    sltStart: '',
    sltEnd: '',
    externalBillingNumber: '',
    externalBillingDateStart: '',
    externalBillingDateEnd: '',
    beddingCondition: '',
    handOver: '',
    expenseNote: '',
    reductionType: '',
    actualCurrency: '',
    officialDeadline: '',
    ourRef: '',
    relevantCaseName: '',
    correlationType: '',
    userId: '',
    userName: '',
    updateUserId: '',
    updateUserName: ''
})

const { pager, getLists, resetPage, resetParams } = usePaging({
    fetchFun: caseLists,
    params: queryParams
})

const handleAdd = async () => {
    showEdit.value = true
    await nextTick()
    editRef.value?.open('add')
}

const handleEdit = async (data: any) => {
    showEdit.value = true
    await nextTick()
    editRef.value?.open('edit')
    editRef.value?.getDetail(data)
}

const handleDelete = async (id: number) => {
    await feedback.confirm('确定要删除？')
    await caseDelete({ id })
    feedback.msgSuccess('删除成功')
    getLists()
}

getLists()
</script>
